<%--
  Created by IntelliJ IDEA.
  User: 26056
  Date: 2021/5/7
  Time: 22:54
  To change this template use File | Settings | File Templates.
--%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<script type="text/javascript" src="../jquery-3.3.1.min.js"></script>
<html>
<head>

    <title>${reqArticle}</title>

    <script>
        var state = ${state};
        $(function () {
            if (state == "1" || state == "2") {
                $("#collect").attr("style", "display:block");
                $("#like").attr("style", "display:block");
                $("#comment").attr("style", "display:block");
                $("#ask").attr("style", "display:block");
                $("#login").attr("style", "display:none");
            } else {
                $("#collect").attr("style", "display:none");
                $("#like").attr("style", "display:none");
                $("#comment").attr("style", "display:none");
                $("#login").attr("style", "display:block");
                $("#ask").attr("style", "display:none");
                alert("你还没登录，不能收藏点赞联系作者哦");
            }
        })

    </script>
</head>

<body>

<div align = "center" >
<h1>${reqArticle}</h1>

<h3>作者：${writer}</h3>

    <form id="ask" action="/DispacherAdd" method="post">
        <input type="hidden" name="reqPerson" value="${writer}">
        <input type="submit" value="联系作者"><br>
    </form>

<p>
    ${article}
</p>

<h4>点赞数：${like}</h4>

    <div id="like">
        <form action="/hitlike" method="post">
            <input type="hidden" name="likeArticle" value="${reqArticle}"><br>
            <input type="submit" value="点赞">
        </form>
    </div>

<div id="collect">
<form action="/AddCollection" method="post">
    <input type="hidden" name="collectArticle" value="${reqArticle}"><br>
    <input type="submit" value="收藏">
</form>
</div>

<h3>
    评论：
</h3>

    <c:if test = "${not empty Comment}" >
        <c:forEach items="${Comment}" var="Comment" varStatus="s">
            <hr color="black" width="30%" size="3" align="center"/>
            ${s.count}. 评论者：${Comment.username}<br><br>
            ${Comment.comment}<br>
            <hr color="black" width="30%" size="3" align="center"/>
        </c:forEach>
    </c:if >
    从这里开始就没有评论了哦~<br>

    <h3>想写评论吗：</h3>

    <div id="login">要登录了才行哦~<br>

    <form  action="/login" method="post">
        <input type="submit" value="点这里登录~">
    </form>
    </div>

    <form id="comment" action="/writeComment" method="post">
        <textarea clos="20" rows="5" name="des"></textarea>
        <input type="hidden" name="articleName" value = "${reqArticle}"><br>
        <input type="submit" value="提交评论">
    </form>

    <form id="comment" action="/writeComment" method="post">
        <textarea clos="20" rows="5" name="des"></textarea>
        <input type="hidden" name="articleName" value = "${reqArticle}"><br>
        <input type="submit" value="提交留言">
    </form>

    <form action="/index.jsp" method="post">
        <input type="submit" value="返回主页">
    </form>

</div>
</body>
</html>
